package com.chanzany.iterator.case1;

public class ComputerCollegeIterator implements Iterator<Department>{
    private final Department[] departments;   //数组的方式组织元素
    private int idx = 0;   //遍历的位置

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        return idx<=departments.length-1;
    }

    @Override
    public Department next() {
        return departments[idx++];
    }

}
